{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">二维码管理</li>
            <li class=""><a href="{:url('admin/qrcode/add')}">新增渠道二维码</a></li>
        </ul>
        <div class="layui-tab-content">
            <hr>

            <form action="" method="post" class="ajax-form">
                <div class="layui-tab-item layui-show">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th style="width: 15px;"><input type="checkbox" class="check-all"></th>
                            <th style="width: 30px;">二维码id</th>
                            <th style="width: 120px;">二维码</th>
                            <th>渠道/公众号</th>
                            <th>过期时间</th>
                            <th>是否过期</th>
                            <th>创建时间</th>
                            <th>备注</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach name = "qrcode_list" item = "v"} 
                        <tr>
                            <td><input type="checkbox" name="ids[]" value="{$v.id}"></td>
                            <td>{$v.qrcode_id}</td>
                            <td><img style="width:100%;" src = "{$v.qrcode}"/></td>
                            <td>{$v.name}</td>
                            <td>{if condition="$v.type eq 'QR_LIMIT_SCENE'"}永久有效{elseif condition="$v.type eq 'QR_SCENE'" /}{if condition="$v.expire egt 3600 && $v.expire lt 3600 * 24"}{$v.expire / 3600}小时{elseif condition="$v.expire elt 3600" /}{$v.expire / 60}分钟{elseif condition="$v.expire egt 3600 * 24"}{$v.expire / (3600 * 24)}天{/if}{/if}</td>
                            <td>{if condition="$v.type eq 'QR_LIMIT_SCENE'"}永久有效{elseif condition="$v.type eq 'QR_SCENE'" /}{if condition="strtotime($v.create_time) + $v.expire gt time()"}<span style="color:green;">未过期</span>{else /}<span style="color:red;">已过期</span>{/if}{/if}</td>
                            <td>{$v.create_time}</td>
                            <td>{$v.remark}</td>
                            <td>
                                <a href="/admin/qrcode/delete/id/{$v.id}" class="layui-btn layui-btn-danger layui-btn-mini ajax-delete">删除</a>
                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                    <!--分页-->
                </div>
            </form>
        </div>
    </div>
</div>
{/block}